package com.cpd.blog.common.utils;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cpd.blog.dto.Page.PageParams;

import java.util.List;

/**
 * @Author: Copydown
 * @Date: 2022/04/30/14:43
 */
public class PageUtil {

    /**
     * 生成对应类的Page对象
     *
     * @param pageParams pageParams
     * @param <T>        T
     * @return Page<T>
     */
    public static <T> Page<T> setPageParams(PageParams pageParams) {
        return new Page<>(pageParams.getPage(), pageParams.getPageSize());
    }

    public static <T> List<T> getPageList(PageParams pageParams, List<T> list) {
        Page<T> page = setPageParams(pageParams);
        page.setRecords(list);
        return page.getRecords();
    }
}
